Device Store
Device related interfaces, operating microphone, camera, etc.
Overview
DeviceStore Device management class for handling host camera, microphone and other business. DeviceStore provides a comprehensive set of APIs to manage audio and video devices, including microphone, camera and screen sharing features.
Key Features
Microphone Management:Open/close microphone, set capture volume and output volume
Camera Management:Open/close camera, switch front/rear camera, set mirror and video quality
Audio Route:Switch between speaker and earpiece
Screen Sharing:Start and stop screen sharing feature
Network Status:Real-time monitoring of network quality information
Important: Use DeviceStore.shared singleton to get the
DeviceStoreinstance. Do not attempt to initialize directly.
Tip: Device state updates are delivered through the deviceState publisher. Subscribe to it to receive real-time updates about microphone, camera, network and other states.
Device Operations Overview
| Feature | Method | Description |
| Microphone | openLocalMicrophone/closeLocalMicrophone | Open/close local microphone |
| Camera | openLocalCamera/closeLocalCamera | Open/close local camera |
| Audio Route | setAudioRoute | Switch speaker/earpiece |
| Screen Sharing | startScreenShare/stopScreenShare | Start/stop screen sharing |
| Volume Control | setCaptureVolume/setOutputVolume | Set capture/output volume |
Usage Example
// Get singleton instance
val store = DeviceStore.shared()
// Subscribe to state changes
lifecycleScope.launch {
store.deviceState.microphoneStatus.collect { status ->
println("Microphone status: $status")
}
}
lifecycleScope.launch {
store.deviceState.cameraStatus.collect { status ->
println("Camera status: $status")
}
}
// Open microphone
store.openLocalMicrophone { code, message ->
if (code == 0) {
println("Microphone opened successfully")
}
}
// Open front camera
store.openLocalCamera(isFront = true) { code, message ->
if (code == 0) {
println("Camera opened successfully")
}
}Topics
Getting Instance
DeviceStore.shared - Singleton object
Observing State
deviceState - Reactive state containing microphone, camera, network and other device states
Microphone Operations
openLocalMicrophone - Open local microphone
closeLocalMicrophone - Close local microphone
setCaptureVolume - Set capture volume
setOutputVolume - Set output volume
Audio Route
setAudioRoute - Set audio route
Camera Operations
startCameraTest - Start camera test
stopCameraTest - Stop camera test
openLocalCamera - Open local camera
closeLocalCamera - Close local camera
switchCamera - Switch camera
switchMirror - Switch mirror state
updateVideoQuality - Update video quality
Screen Sharing
startScreenShare - Start screen sharing
stopScreenShare - Stop screen sharing
Reset
reset - Reset to default state
See Also
Functions
Close local camera
Close local microphone
Open local camera
Open local microphone
Set audio route
Set capture volume
Set maximum output volume
Start camera test, if camera opens successfully, the view will be rendered to the set CameraView
Start screen sharing
Stop camera test
Stop screen capture
Switch camera
Switch mirror state
Update video quality